if (!_ostree_sysroot_ensure_boot_fd (sysroot, error))
return FALSE;
-
g_assert_cmpint (sysroot->boot_fd, !=, -1);
+ // We use symlinks here.
+ g_assert (!sysroot->boot_is_vfat);
/* The symlink was already written, and we used syncfs() to ensure
* its data is in place. Renaming now should give us atomic semantics;
#include "otutil.h"
#include <err.h>
+#include <linux/magic.h>
#include <sys/file.h>
#include <sys/mount.h>
+#include <sys/vfs.h>
#include <sys/wait.h>
#include "ostree-bootloader-aboot.h"
return TRUE;
}
+static gboolean
+validate_boot_fd (OstreeSysroot *self, int fd, GError **error)
+{
+ g_assert_cmpint (fd, !=, -1);
+ struct statfs stbuf;
+ if (fstatfs (fd, &stbuf) < 0)
+ return glnx_throw_errno_prefix (error, "fstatfs(boot)");
+ self->boot_is_vfat = (stbuf.f_type == MSDOS_SUPER_MAGIC);
+ if (self->boot_is_vfat)
+ return glnx_throw (error, "/boot cannot currently be a vfat filesystem");
+ return TRUE;
+}
+
/* Require that both self->sysroot_fd is set.
* If the sysroot has a boot/ subdirectory, it will be loaded.
* If not, self->boot_fd will remain -1.
return FALSE;
if (self->boot_fd == -1)
{
- int fd = glnx_opendirat_with_errno (self->sysroot_fd, "boot", TRUE);
+ glnx_autofd int fd = glnx_opendirat_with_errno (self->sysroot_fd, "boot", TRUE);
if (fd < 0)
{
if (errno != ENOENT)
return glnx_throw_errno_prefix (error, "Opening boot/");
}
else
- self->boot_fd = fd;
+ {
+ if (!validate_boot_fd (self, fd, error))
+ return FALSE;
+ self->boot_fd = glnx_steal_fd (&fd);
+ }
}
return TRUE;
}
return FALSE;
if (self->boot_fd == -1)
{
- if (!glnx_opendirat (self->sysroot_fd, "boot", TRUE, &self->boot_fd, error))
+ glnx_autofd int fd = -1;
+ if (!glnx_opendirat (self->sysroot_fd, "boot", TRUE, &fd, error))
+ return FALSE;
+ if (!validate_boot_fd (self, fd, error))
return FALSE;
+ self->boot_fd = glnx_steal_fd (&fd);
}
return TRUE;
}
--- /dev/null
+#!/bin/bash
+
+# Run test-basic.sh as root.
+# https://github.com/ostreedev/ostree/pull/1199
+
+set -xeuo pipefail
+
+if test $(readlink /proc/1/ns/mnt) = $(readlink /proc/self/ns/mnt); then
+ exec unshare -m -- "$0" "$@"
+fi
+
+. ${KOLA_EXT_DATA}/libinsttest.sh
+
+# Use /var/tmp to hopefully use XFS + O_TMPFILE etc.
+prepare_tmpdir /var/tmp
+trap _tmpdir_cleanup EXIT
+
+truncate -s 512M boot.img
+mkfs.vfat boot.img
+
+mkdir sysroot
+ostree admin init-fs -E 1 sysroot
+mount -o loop boot.img sysroot/boot
+if ostree admin status --sysroot=sysroot 2>err.txt; then
+ # So cleanup works on failure too
+ umount sysroot/boot
+ fatal "computed status on vfat sysroot"
+fi
+umount sysroot/boot
+assert_file_has_content_literal err.txt "/boot cannot currently be a vfat filesystem"